﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Domain;
using Persistence.Dao;
using Persistence;
namespace web.manage
{
    public partial class News_Manage : adminBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                bind();
            }
        }
        private void bind()
        {
            repList.DataSource = Singleton<NewsDao>.Instance.GetModels("*", "newstype="+ddltype.SelectedValue, "[newsid] desc", AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex);
            repList.DataBind();
        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            bind();
        }

        protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            int id = Common.Utils.StrToInt(e.CommandArgument, 0);
            if (id > 0)
            {
                News p = new News();
                p.newsId = id;
                Singleton<NewsDao>.Instance.Delete(p);
                Common.Message.alert("删除成功");
                bind();
            }
        }
         

        protected void Button1_Click(object sender, EventArgs e)
        {
            bind();
        }
    }
}
